-
Notifications
You must be signed in to change notification settings - Fork 15.6k
Nested Collections: "immutable" arrays, Clarify independence of inner arrays in nested collections example #30215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested Collections: "immutable" arrays, Clarify independence of inner arrays in nested collections example #30215
Conversation
|
The explicit explanation is indeed a welcome addition. I'd still give a few more minutes on how to avoid using the word immutable in the paragraph above it. |
|
@oz123 so that i can make it nested_arrays? so that i can be more simpler to understand? |
|
I was referring to the paragraph that starts with:
This feels very confusing for me. This example : I think this should not be termed "mutable" but as "caution" this syntax is not doing what you expect. I would first show the "correct" way to create the collection:
And than add a caution block that shows what happens with the syntax:
Thank you for your effort on this. |
JoshDevHub
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good idea. Also for clarity, when you say
This might confuse students coming from other languages where “immutable” has a stricter meaning.
It also has a strict meaning in the Ruby language. The example given in the lesson is just incorrect with its use of mutable/immutable
Anyways, before I approve, I think the example given above your changes should be altered as well. The line that says:
To create an immutable array of mutable objects (string, array, hash, etc), you will need to pass the default value for Array.new via a block, using curly braces, instead of the second optional argument.
Probably needs to be something like this (omitting the incorrect 'immutable' word):
To correctly create an array of mutable objects (string, array, hash, etc), you will need to pass the default value for Array.new via a block, using curly braces, instead of the second optional argument.
The variable name in the example below that could probably be changed to nested_array as well instead of mutable.
How do these changes sound?
|
@JoshDevHub i have change its to nested_arrays, could you verified it once #30215 |
|
@JoshDevHub, updated PR. #30215 |
oz123
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is better.
Because
The lesson currently uses the term immutable incorrectly. The example:
This might confuse students coming from other languages where “immutable” has a stricter meaning. A clearer description would help avoid misunderstanding.
This PR
Issue
Pull Request Requirements
location of change: brief description of changeformat, e.g.Intro to HTML and CSS lesson: Fix link textBecausesection summarizes the reason for this PRThis PRsection has a bullet point list describing the changes in this PRIssuesection